task line生成関数
code:generate.d.ts
export function generate(date: Date): Promise<{
title: string;
baseDate: Date;
plan?: {
start?: Date;
duration?: DateFns.Duration;
};
}[]>;
generate.jsに書く
与えられた日付にこのタスクをやるかどうかを判定する
一日に複数回やる場合も考えられるので、配列で返す
その日にする予定がない場合は、空配列を返す
例
code:generate.js
import {isToday, set} from '../date-fns.min.js/script.js';
export async function generate(date) {
if (isToday(date)) return [];
return [{
title: 'test task',
baseDate: date,
plan: {
start: set(date, {hours: 13, minutes: 30}),
duration: {minutes: 45},
},
}];
}
helper関数
Taskの型定義を変えた
code:helper.d.ts
import type { Task } from "../takker99%2Ftakker-scheduler/deps.ts";
/** helper function for creating Task easily */
export function create(title: string, start: Date, duration: number): Task;
code:helper.js
export function create(title, start, duration) {
return {
title,
base: start,
plan: {
start,
duration: duration * 60,
},
};
}
code:helper.js.old(js)
export function create(title, start, estimate) {
return {
title,
baseDate: start,
plan: {
start,
duration: {minutes: estimate},
},
};
}